module.exports = function (req, res) {

  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
  res.header("X-Powered-By", " 3.2.1");
  res.header("Content-Type", "application/json;charset=utf-8");


  var { username, password } = req.body;
  if (!username) {
    res.status(403).send({ error: 1, data: "用户名未填写", message: "请求失败" });
    return;
  }
  if (!password) {
    res.status(403).send({ error: 2, data: "密码未填写", message: "请求失败" });
    return;
  }
  
  req.session.name = username;
  res.json({
    error: 0,
    data: "登录成功",
    message: "请求成功",
  });
};
